﻿using StoreTools.Online.Model;
using StoreTools.Online.ViewModel;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;


namespace StoreTools.Online.View
{
    /// <summary>
    /// LogWindow.xaml 的交互逻辑
    /// </summary>
    public partial class LogWindow : Window
    {
        public LogWindow()
        {
            InitializeComponent();
            logViewModel = new LogViewModel();
            logModel = new LogModel();
            this.DataContext = logModel;
        }

        public LogViewModel logViewModel { get; set; }
        public LogModel logModel { get; set; }

        private void WinMove_LeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.Dispatcher.Invoke(new Action(delegate
            {
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    this.DragMove();
                }
            }));
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            
            this.Dispatcher.Invoke(new Action(delegate
            {
                this.Hide();
            }));
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.Dispatcher.Invoke(new Action(delegate
            {
                this.WindowState = WindowState.Minimized;
            }));
        }

        private void LogTextBox_TtextChanged(object sender, TextChangedEventArgs e)
        {
            this.Dispatcher.Invoke(new Action(delegate
            {
                LogtextScrollViewer.ScrollToEnd();
            }));
        }

        private void MenuItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            this.Dispatcher.Invoke(new Action(delegate
            {
                logModel.CleanInfo();
            }));
        }
    }
}
